﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GuildStock.Models
{
  /// <summary>
  /// Zones
  /// </summary>
  public enum Zones { US, EU, KR, CN, TW }

  /// <summary>
  /// Zone helpers.
  /// </summary>
  public static class ZonesExtensions
  {
    /// <summary>
    /// Extracts zone from realm name.
    /// </summary>
    public static Zones ExtractZone(this string realm)
    {
      var delimiterIndex = realm.IndexOf('-');
      return delimiterIndex > 0 ? (Zones)Enum.Parse(typeof(Zones), realm.Substring(delimiterIndex + 1)) : Zones.US;
    }

    /// <summary>
    /// Extracts zone from realm name.
    /// </summary>
    public static string ExtractRealmName(this string realm)
    {
      var delimiterIndex = realm.IndexOf('-');
      return delimiterIndex > 0 ? realm.Substring(0, delimiterIndex) : realm;
    }

    /// <summary>
    /// Combines realm name and zone.
    /// </summary>
    public static string FullName(string realm, Zones zone)
    {
      return string.Format("{0}-{1}", realm, zone.ToString());
    }

    /// <summary>
    /// Combines realm name and zone.
    /// </summary>
    public static string FullName(string realm, string zone)
    {
      return string.Format("{0}-{1}", realm, zone);
    }
  }
}